﻿function CheckAll(form) {
    for (var i = 0; i < form.elements.length; i++) {
        var e = form.elements[i];
        if (e.name != 'chkall') e.checked = form.chkall.checked;
    }
}
//<a href="javascript:check('ids',2);">反选</a>
//<a href="javascript:check('ids',0);">全部选择</a>|
//<a href="javascript:check('ids',1);">清除选择</a>|
/***checkbox多选.***/
function check(name, k) {
    var el = document.getElementsByTagName('input');
    var len = el.length;
    for (var i = 0; i < len; i++) {
        if ((el[i].type == "checkbox") && (el[i].name == name)) {
            if (k == 0) {
                el[i].checked = true;
            }
            if (k == 1) {
                el[i].checked = false;
            }
            if (k == 2) {
                el[i].checked = !el[i].checked;
            }
        }
    }
}

function DataFormat() {
    var dt;
    var date = new Date();
    var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
    var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
    var currentHH = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
    var currentmm = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
    var currentss = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
    return date.getFullYear() + "-" + month + "-"
    + currentDate + " " + currentHH + ":" + currentmm + ":" + currentss;
}

//获取现在项值
function CheckValue() {
    var bepost="";
    $("[name='cb']").each(function (i, cb) {
        if (cb.checked) {
            bepost += (cb.value + "|");
        }
    });
    if (bepost == 0) {
        alert("你没有选中任何项?!");
        return "";
    }
    return bepost;
}

function isEdite(url) {
    window.location = url;
}


function isdel() {
    var ok = confirm("确定删除吗?删除后数据不能恢复!请小心删除!")
    if (!ok) return false
    else return true;
}
function isAlertError() {
  alert("数据操作错误,请稍后再试。");
}
function showBtnOver(obj) {
    if (obj.className.indexOf("Over") == -1)
        obj.className = obj.className + "Over";
}

function showBtnOut(obj) {
    if (obj.className.indexOf("Over") > -1)
        obj.className = obj.className.replace("Over", "");
}

function isExc() {
    var ok = confirm("确定执行操作吗?!")
    if (!ok) return false
    else return true;
}

function ref()
{
    window.location.reload();
    document.cookie="SeatCode=";
    document.cookie="SeatPrice=";
    document.cookie="SeatColor=";
}

function trOnMouseOver() {

   //this.style.backgroundColor = "#DBE3FA";
}
function trOnMouseOut() {
   // this.style.backgroundColor = "#F6F6F6";
}


//反序列化返回值
function jsonToRssObject(json) {
    return eval("(" + json + ")");
}

//浮点数乘法运算
function FloatMul(arg1, arg2) {
    var m = 0, s1 = arg1.toString(), s2 = arg2.toString();
    try { m += s1.split(".")[1].length } catch (e) { }
    try { m += s2.split(".")[1].length } catch (e) { }
    return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m)
}
//判断金额
function IsMoney(M) {
    var a = /^[0-9]*(\.[0-9]{1,2})?$/;
    if (a.test(M)) {
        return true;
    }
}
//判断文件格式
function IsFileFormat(file) {
    var filepath = $("input[name='" + file + "']").val();
    var extStart = filepath.lastIndexOf(".");
    var ext = filepath.substring(extStart, filepath.length).toUpperCase();
    if (ext != "fr3") {
        alert("文件格式错误！.fr3");
        return false;
    }
}
//josn返回时间格式格式化
function ChangeDateFormat(cellval) {
    var date = new Date(parseInt(cellval.replace("/Date(", "").replace(")/", ""), 10));
    var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
    var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
    var currentHH = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
    var currentmm = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
    var currentss = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
    return date.getFullYear() + "-" + month + "-"
    + currentDate + " " + currentHH + ":" + currentmm + ":" + currentss;
}
//----------------Js获取URL参数值 开始---------------
function Request(paras) {
    var url = location.href;
    var paraString = url.substring(url.indexOf("?") + 1, url.length).split("&");
    var paraObj = {}
    for (i = 0; j = paraString[i]; i++) {
        paraObj[j.substring(0, j.indexOf("=")).toLowerCase()] = j.substring(j.indexOf("=") + 1, j.length);
    }
    var returnValue = paraObj[paras.toLowerCase()];
    if (typeof (returnValue) == "undefined") {
        return "";
    } else {
        return returnValue;
    }
}
//----------------Js获取URL参数值 结束--------------- 